<template>
    <div>
        <header>
            <div class="wrap">
                <div class="left-theme">
                    <div class="iconbox"><i class="iconfont icon-renyuanzu-shi"></i></div>
                    <h2>智慧物业管理系统</h2>
                </div>
                <div>
                    <button class="exitbtn" @click="LogOut">退出系统</button>
                </div>
            </div>
        </header>
        <main>
            <div class="wrap">
                <ul class="navlistbox">
                    <li class="navlist-item" v-for="(item, index) in communityListdata" :key="index"
                        @click="jump(item.id)">
                        <div class="ComImg">
                            <!-- 小区图片 -->
                        </div>
                        <div class="Comitembox">
                            <div class="Comtext">
                                <h2>{{ item.community }}</h2>
                                <p>{{ item.address }}</p>
                            </div>
                            <div class="Combtnbox">
                                <router-link to="/workbench">管理</router-link>
                                <router-link to="#">编辑</router-link>
                                <router-link to="#">删除</router-link>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </main>
    </div>
</template>

<script>
//小区列表接口  
import { community } from '@/config/api'
export default {
    name: 'communityList',

    data() {
        return {
            communityListdata: []
        };
    },

    mounted() {
        this.communityListdataFn()
    },

    methods: {
        async communityListdataFn() {
            let { data: res } = await community();
            this.communityListdata = res.data.community
            // console.log(res)

        },
        jump(id) {
            // console.log(id)
            this.$router.push("/workbench")

        },
        LogOut() {
            window.localStorage.removeItem("token")
            this.$router.replace("/login")
        }
    },
};
</script>

<style lang="less" scoped>
.wrap {
    margin: 0 auto;

    width: 1200px;




}

header {
    background-color: #fff;
    height: 60px;

    .wrap {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 100%;

        .left-theme {
            display: flex;
            align-items: center;

            .iconbox {
                width: 35px;
                height: 35px;
                background-color: #0B7DFF;
                border-radius: 50%;
                text-align: center;
                line-height: 35px;
                margin-right: 10px;

                i {
                    color: #fff;
                    font-size: 24px;

                }
            }

            h2 {
                font-size: 18px;
            }

        }

        .exitbtn {
            font-size: 14px;
            background-color: transparent;

        }

        .exitbtn:hover {
            color: #0B7DFF;
            cursor: pointer;
        }
    }
}

main {
    .wrap {
        margin-top: 20px;

        .navlistbox {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            flex-wrap: wrap;

            .navlist-item:hover {
                border: none;

                box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.5);

                .Comtext {
                    h2 {
                        color: #0B7DFF;
                    }
                }
            }

            .navlist-item {
                width: 270px;
                margin: 0 20px 20px 0;
                border: 1px solid #E9E9E9;
                height: 290px;

                .Comitembox {
                    background-color: #ffff;
                    height: 140px;
                }

                .ComImg {
                    width: 100%;
                    height: 150px;
                    background-color: #F1F5FB;

                }

                .Comtext {
                    padding: 20px;
                    box-sizing: border-box;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;

                    h2 {
                        font-size: 16px;
                    }

                    p {
                        font-size: 14px;
                        color: #999;
                        margin-top: 5px;
                    }
                }

                .Combtnbox {
                    border-top: 1px solid #f5f5f5;
                    display: flex;
                    align-content: center;
                    justify-content: space-around;
                    height: 50px;

                    a {
                        display: inline-block;
                        border-right: 1px solid #f5f5f5;
                        height: 50px;
                        line-height: 50px;
                        font-size: 14px;

                    }

                    a:last-child {
                        border: none;
                        color: #F46363;

                    }
                }
            }

            .navlist-item:last-child {
                margin-right: 0;
            }
        }
    }
}
</style>